#ifndef UMLPROJECT_H
#define UMLPROJECT_H

#include <QGraphicsScene>
#include <QString>
#include <QUuid>
#include <QList>
#include <QAction>
#include <QToolBar>
#include <QToolBar>
#include <QDockWidget>
#include <QDebug>

#include "uml/datatypedictionary.h"
#include "uml/relations/draggedrelation.h"

class UmlDirItem;
class MainWindow;
class UmlGraphicsItem;
class ProjectModel;
class UmlItem;

class UmlProject : public QGraphicsScene
{
    Q_OBJECT
public:
    enum ProjectType {
        GenericProject,
        ClassDiagramm
    };

    UmlProject(QObject *parent = 0);
    ~UmlProject();

    QString id();
    void setId(QString id);

    QString name();
    void setName(QString name);

    QString path();
    void setPath(QString path);

    UmlProject::ProjectType type();
    void setType(UmlProject::ProjectType type);

    UmlDirItem* umlItemRoot();
    void setUmlItemRoot(UmlDirItem *root);

    DatatypeDictionary* dataTypes();
    void setDataTypes(DatatypeDictionary *dataTypes);

    void setMainWindow(MainWindow *mainWindow);

    void addUmlitem(UmlDirItem *dir, UmlGraphicsItem *item);
    void removeUmlItem(UmlGraphicsItem *item);

    DraggedRelation *draggedRelation();
    bool hasDraggedRelation();

    void showGuides(bool showGuides);

    UmlGraphicsItem* itemUnderMouse(QPointF pos);

    QRectF selectionRect();

    void mousePressEvent(QGraphicsSceneMouseEvent *event);
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event);

    virtual void initToolbar(QToolBar *toolbar);
    virtual QDockWidget* itemDock();

    ProjectModel* model();

public slots:
    void drawPackage(UmlDirItem *dir);
    void startRelationDrag(DraggedRelation *draggedRelation);

protected:
    QString _id;
    QString _name;
    QString _path;
    ProjectType _type;
    UmlDirItem *_umlItemRoot;
    UmlDirItem *_currentDir;
    ProjectModel *_model;

    DraggedRelation *_draggedRelation;

    bool _isPressed;
    bool _drawGuides;

    DatatypeDictionary *_dataTypes;

    MainWindow *_mainWindow;

    QGraphicsLineItem *_topBorder;
    QGraphicsLineItem *_bottomBorder;
    QGraphicsLineItem *_leftBorder;
    QGraphicsLineItem *_rightBorder;

    void drawGuides();

};

#endif // UMLPROJECT_H
